using System;

namespace LogikBug
{
	/// <summary>
	/// 
	/// </summary>
	public static class TypeExtensions
	{
		/// <summary>
		/// 
		/// </summary>
		/// <param name="derivedType"></param>
		/// <returns></returns>
		public static bool Inherits<T>(this Type derivedType)
		{
			derivedType.ThrowIfNull("derivedType");
			return typeof(T).Inherits(derivedType);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="derivedType"></param>
		/// <param name="baseType"></param>
		/// <returns></returns>
		public static bool Inherits(this Type derivedType, Type baseType)
		{
			derivedType.ThrowIfNull("derivedType");
			baseType.ThrowIfNull("baseType");

			return baseType.IsAssignableFrom(derivedType);
		}
	}
}